package com.skt.common_hr.common.puremvc
{
	import com.skt.common_hr.common.AppModuleManager;
	import com.skt.common_hr.common.Constants;
	import com.skt.common_hr.common.Messages;
	import com.skt.common_hr.common.StatusMsgVO;
	
	import mx.core.UIComponent;
	
	import org.puremvc.as3.multicore.interfaces.IFacade;
	import org.puremvc.as3.multicore.patterns.facade.Facade;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;

	public class CommonMediator extends Mediator
	{
		protected var bActivated:Boolean = true;
		protected var bDirty:Boolean = false;
		
		private var _status:String = Constants.STATE_INITIAL;
		
		/**
		* 생성자
		* 
		* @param
		* @return void
		*/
        public function CommonMediator( name:String, viewComponent:Object )
        {
            super( name, viewComponent );
            if(viewComponent!=null) {
	            bActivated = true;
	            (viewComponent as UIComponent).callLater(initializeView);
	          }
        }
		
		public function get status():String {
			return _status;
		}
		
		public function set status(s:String):void
		{
			switch(s) {
			case Constants.STATE_IDLE:
			case Constants.STATE_INITIAL:
			case Constants.STATE_LOADING_DATA:
			case Constants.STATE_SLEEP_MODULE:
			case Constants.STATE_UPDATING_DATA:
				_status = s;
				break;
			default:
				trace("invalid status(" + s + ") in module : " + this.mediatorName);
				//_status = Constants.STATE_IDLE:
				break;
			}
			
		}
		
		/**
		* View를 초기화 한다.
		*	- View에 기본사항을 출력하고 data를 load
		* @param
		* @return void
		*/
 		protected function initializeView():void
 		{
 		}

		protected function clearView():void
		{
		}
		

		// Return the Multiton Facade instance 
		protected function get mainFacade():IFacade
		{
			if ( AppModuleManager.MODULE_KEY_MAIN == null ) throw Error( MULTITON_MSG );
			return Facade.getInstance( AppModuleManager.MODULE_KEY_MAIN );
		}
		

		
		protected function get commonFacade():CommonFacade
		{
			return facade as CommonFacade;
		}
	}
}